package com.huel.components;

import android.os.CountDownTimer;
import android.widget.TextView;

import com.huel.taobaostore.R;

public class TimeCount extends CountDownTimer {
    private TextView tvCode;
    public TimeCount(long millisInFuture, long countDownInterval) {
        super(millisInFuture, countDownInterval);
    }

    public TimeCount(long millisInFuture, long countDownInterval, TextView tv) {
        super(millisInFuture, countDownInterval);
        this.tvCode = tv;
    }

    @Override
    public void onTick(long millisUntilFinished) {
        tvCode.setBackgroundResource(R.drawable.circle_corner_button_pressed);
        tvCode.setTextSize(15);
        tvCode.setText("等待"+millisUntilFinished / 1000 +"秒");
        tvCode.setClickable(false);
    }

    @Override
    public void onFinish() {
        tvCode.setBackgroundResource(R.drawable.circle_corner_button);
        tvCode.setTextSize(15);
        tvCode.setText("获取验证码");
        tvCode.setClickable(true);
    }
}
